/*
 * All rights Reserved, Designed By DataDriver
 * Copyright:    DataDriver.Inc
 * Company:      Zhuo Wo Infomation Technology (ShangHai) CO.LTD
 */
package com.sun.add;

import java.util.concurrent.CountDownLatch;
import java.util.concurrent.CyclicBarrier;

/**
 * 计数器+1
 */
public class CountDownLatchDemo {

    public static void main(String[] args) throws InterruptedException {
        //设置初始容量
        CountDownLatch count = new CountDownLatch(4);

        for (int i = 1; i <=4; i++) {
            final int temp  = i;
            new Thread(()->{
                count.countDown();
                System.out.println(temp + "go out");
            },String.valueOf(i)).start();
        }
        count.await(); //等待计数器为0
        System.out.println("close door");

    }
}
